/**
 * Copyright (c) 2018-2019 PoleStar Studio. All Rights Reserved. <br>
 * Use is subject to license terms.<br>
 * <p>
 * 在此处填写文件说明
 */
package springjdbc;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * Spring中的JDBC编程测试.
 * <p>说明.<br>
 *     1.指定Spring配置文件路径
 *     2.创建Spring容器
 *     3.从容器中，获取bean
 *     4.使用jdbcTemplate的execute方法，创建account数据表（id，username，balance）
 *                  "create table account(id int primary key auto_increment," +
 *                 "username varchar(50)," +
 *                 "balance double )" +
 *                 "engine=innodb,collate=utf8_general_ci";
 * @version v1.0
 * @author lianzuozheng
 * @date 2019-03-21 -18:00
 */
public class Test {

    public static void main(String[] args) {
        /** 1.指定Spring配置文件路径  */
        String xmlPath= "file:D:\\Springlearning1\\src\\springjdbc\\beans.xml";
        /** 2.创建Spring容器  */
        ApplicationContext ac = new ClassPathXmlApplicationContext(xmlPath);
        /** 3.从容器中获取bean  */
        JdbcTemplate jdbcTemple = (JdbcTemplate)ac.getBean("jdbcTemplate");
        /** 4.使用jdbcTemplate的execute方法，创建account用户账户表 */
        String sql="create table account(" +
                "id int primary key auto_increment," +
                "username varchar (50)," +
                "balance double)" +
                "engine=innodb,collate=utf8_general_ci";

        jdbcTemple.execute(sql);

        System.out.println("account数据表创建成功!");

    }

}
